package com.cainezhu.coolwind.utils;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class SpringFactoryUtils {
	public static final String PATH = "/com/cainezhu/coolwind/configs/spring/applicationContext.xml";
	public static ApplicationContext context = null;
	
	public static ApplicationContext getApplicationContext(String path){
		if(context==null){
		context = new ClassPathXmlApplicationContext(path);
		}
		return context;		
	}
	
	public static ApplicationContext getApplicationContext(){
		if(context==null){
		context = new ClassPathXmlApplicationContext(PATH);
		}
		return context;		
	}
	
	public static Object getBean(String name , Class cl){
		return getApplicationContext().getBean(name, cl);
	}
	public static Object getBean(String name , Object cl){
		return getApplicationContext().getBean(name, cl);
	}
}
